package com.lovo.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lovo.bean.Tender2;
import com.lovo.dto.TenderDto;
import com.lovo.mapper.Tender2Mapper;
import com.lovo.service.ITender2Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Service;



/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author lovo
 * @since 2022-09-17
 */
@Service
public class Tender2ServiceImpl extends ServiceImpl<Tender2Mapper, Tender2> implements ITender2Service {

    @Autowired
    Tender2Mapper tender2Mapper;

    @Autowired
    MQSService mqsService;


    @Override
    public void sendTender(Tender2 tender2) {
        tender2Mapper.insert(tender2);
        TenderDto tenderDto = new TenderDto();
        BeanUtils.copyProperties(tender2, tenderDto);
        mqsService.sendTender(tenderDto);

    }

    @Override
    public void updateTender(Integer tenderId) {
        Tender2 tender2 = tender2Mapper.selectById(tenderId);
        tender2.setTStatus("已招标");
        tender2Mapper.updateById(tender2);
    }

    @Override
    public IPage<Tender2> findAllTender(Integer pageNo) {

        return tender2Mapper.selectPage(new Page<>(pageNo, 5), null);

    }

}
